package com.youhome.service.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.youhome.service.mapper.BLogMapper;
import com.youhome.service.model.BLog;
import com.youhome.service.service.BLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by chen365 on 2017/10/19.
 */
@Service
public class BLogServiceImpl implements BLogService {
    @Autowired
    private BLogMapper bLogMapper;

    @Override
    public int save(BLog log) {
        return bLogMapper.insertSelective(log);
    }

    @Override
    public PageInfo<BLog> selectByBean(Integer page, Integer pageSize, BLog bLog) {

        if (page == null || page < 1) {
            page = 1;
        }
        if (pageSize == null || pageSize < 1) {
            pageSize = 10;
        }
        PageHelper.startPage(page, pageSize);
        List<BLog> list = bLogMapper.selectByBean(bLog);
        return new PageInfo<>(list);
    }

}
